/*
 * 4.3.cpp 1002
 *
 *  Created on: 2012-5-18
 *      Author: jawinton
 */

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>

using namespace std;

#define SIZE 100000
#define LEN 9

char str[100],tels[SIZE][LEN];
char map[]="22233344455566677778889999";

/**
 * Returns an integral value indicating the relationship between the strings:
 * A zero value indicates that both strings are equal.
 * A value greater than zero indicates that the first character
 * that does not match has a greater value in str1 than in str2;
 * And a value less than zero indicates the opposite.
 */
int compare(const void * elem1, const void * elem2) {
	return strcmp((char *)elem1, (char *)elem2);
}
/*
char* standardizeTel(char *tel) {
	char * pch;
	char ret[LEN];
	pch = strtok(tel,"-");
	while (pch != NULL) {
		strcat(ret,pch);
		pch = strtok(NULL, "-");
	}
	for(int i=0; i<LEN-1; i++) {
		ret[i] = map[ret[i]-'a'];
	}
	for(int i=LEN-2; i>2; i--) {
		ret[i] = ret[i-1];
	}
	ret[LEN-1] = '\0';
	return ret;
}*/

void standardizeTel(int n) {
	int i=-1, k=-1;
	while (k < 8) {
		i++;
		if (str[i] == '-') continue;
		k++;
		if (k == 3) {
			tels[n][k] = '-';
			k++;
		}
		if (str[i] >= 'A' && str[i] <= 'Z') {
			tels[n][k] = map[str[i]-'A'];
			continue;
		}
		tels[n][k] = str[i];
	}
	tels[n][k] = '\0';
	return;
}

int main (void) {
	int n;
	cin >> n;
	for (int i=0; i<n; i++) {
		scanf("%s",str);
		//strcpy(tels[i],standardizeTel(str));
		//cout << tels[i] << endl;
		standardizeTel(i);
	}
	qsort(tels, n, LEN, compare);
	/*
	int k = 0, redupNum = 1;
	for (int i=1; i<n; i++) {
		if (strcmp(tels[k], tels[i]) == 0) {
			redupNum ++;
		} else {
			if (redupNum > 1)
				cout << tels[k] << " " << redupNum << endl;
			redupNum = 1;
			k = i;
		}
	}
	if (k == 0 && redupNum == 1)
		cout << "No duplicates." << endl;
	*/
	bool nodup = true;
	int i = 0, k;
	while(i < n) {
		k = i;
		i++;
		while (i < n && strcmp(tels[k], tels[i]) == 0) i++;
		if (i - k > 1) {
			nodup = false;
			cout << tels[k] << " " << i - k << endl;
		}
	}
	if (nodup)
		cout << "No duplicates." << endl;
	return 0;
}
